package com.pt.manage.service.impl;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.pt.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.pt.manage.mapper.NotificationMapper;
import com.pt.manage.domain.Notification;
import com.pt.manage.service.INotificationService;
import com.pt.manage.domain.vo.voNotification;
/**
 * 通知Service业务层处理
 * 
 * @author wxt
 * @date 2025-02-20
 */
@Service
public class NotificationServiceImpl implements INotificationService 
{
    @Autowired
    private NotificationMapper notificationMapper;

    /**
     * 查询通知
     * 
     * @param NotificationID 通知主键
     * @return 通知
     */
    @Override
    public Notification selectNotificationByNotificationID(Long NotificationID)
    {
        return notificationMapper.selectNotificationByNotificationID(NotificationID);
    }

    /**
     * 查询通知列表
     * 
     * @param notification 通知
     * @return 通知
     */
    @Override
    public List<voNotification> selectNotificationList(Notification notification)
    {
        notification.setTeacherID(SecurityUtils.getUserId());
        return notificationMapper.selectNotificationList(notification);
    }

    /**
     * 查询学生通知列表
     *
     * @param notification 通知
     * @return 通知
     */
    @Override
    public List<voNotification> selectsNotificationList(Notification notification)
    {
        Long studentId = SecurityUtils.getUserId();
        Map<String, Object> params = new HashMap<>();
        params.put("studentId", studentId); // 传入具体的 teacherid
        params.put("notification", notification); // 传入 trainingcourse 对象
        return notificationMapper.selectsNotificationList(params);
    }
    /**
     * 新增通知
     * 
     * @param notification 通知
     * @return 结果
     */
    @Override
    public int insertNotification(Notification notification)
    {
        notification.setTeacherID(SecurityUtils.getUserId());
        notification.setReleaseTime(new Date());
        return notificationMapper.insertNotification(notification);
    }

    /**
     * 修改通知
     * 
     * @param notification 通知
     * @return 结果
     */
    @Override
    public int updateNotification(Notification notification)
    {
        return notificationMapper.updateNotification(notification);
    }

    /**
     * 批量删除通知
     * 
     * @param NotificationIDs 需要删除的通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationByNotificationIDs(Long[] NotificationIDs)
    {
        return notificationMapper.deleteNotificationByNotificationIDs(NotificationIDs);
    }

    /**
     * 删除通知信息
     * 
     * @param NotificationID 通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationByNotificationID(Long NotificationID)
    {
        return notificationMapper.deleteNotificationByNotificationID(NotificationID);
    }
}
